FROM golang:alpine

ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.io

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
&& apk add --no-cache git wget protobuf \
&& wget https://github.com.cnpmjs.org/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip \
&& unzip protoc-3.6.1-linux-x86_64.zip -d /usr/local/ -x bin/protoc \
&& rm protoc-3.6.1-linux-x86_64.zip \
&& go get -u google.golang.org/grpc \
&& go get -u github.com/golang/protobuf/protoc-gen-go \
&& go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger \
&& go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \
&& go get -u github.com/mwitkow/go-proto-validators/protoc-gen-govalidators \
&& go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc \
&& go get -u github.com/golang/mock/gomock \
&& go get -u github.com/golang/mock/mockgen \
# github地址换成国内更快的镜像地址
&& git clone https://github.com.cnpmjs.org/grpc-ecosystem/grpc-gateway.git /go/src/github.com/grpc-ecosystem/grpc-gateway \
&& git clone https://github.com.cnpmjs.org/mwitkow/go-proto-validators.git /go/src/github.com/mwitkow/go-proto-validators

WORKDIR /opt/protos